//
//  Protocols.swift
//  PerfectServer
//
//  Created by 王薰怡 on 2017/6/28.
//
//

import Foundation

//MARK: - 反射
protocol Reflectable {
    func propertyInfos() -> [String: Any]
}

extension Reflectable {
    func propertyInfos() -> [String: Any] {
        var result : [String: Any] = [:]
        let children = Mirror(reflecting: self).children
        for child in children {
            if let name = child.label {
                result[name] = child.value
            }
        }
        return result
    }
}
